package com.example.demo.mapper;

import com.example.demo.entity.Reckoning;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface ReckoningMapper {
    @Insert("insert into reckoning(CustomerId,Money,Date) values(#{CustomerId},#{Money},#{Date})")
    void insertReckoning(Reckoning reckoning);

    @Select("select Sum(Money) as Money,CustomerId,DATE_FORMAT(Date, '%Y-%m-%d') as Date from reckoning where CustomerId=#{id} group by  DATE_FORMAT(Date, '%Y-%m-%d') desc")
    List<Reckoning> selectReckoningByD(String id);

    @Select("select Sum(Money) as Money,CustomerId,DATE_FORMAT(Date, '%Y-%m') as Date from reckoning where CustomerId=#{id} group by  DATE_FORMAT(Date, '%Y-%m') desc")
    List<Reckoning> selectReckoningByY(String id);
}
